#include <iostream>
#pragma comment(lib,"../Debug/Dll")

int main()
{
    int * d2;
    {
        cudaError_t e1 = cudaMalloc((void**)&d2, sizeof(int));
        std::cout << "alloc d2 = " << d2 << " err = " << e1 << std::endl;
    }
    {
        short * d;
        cudaError_t e1 = cudaMalloc((void**)&d, sizeof(short));  // Not correct size.
        std::cout << "alloc = " << d << " err = " << e1 << std::endl;
        cudaError_t e2 = cudaFree(d);
        std::cout << "free  = " << d << " err = " << e2 << std::endl;
    }
    {
        int* hostA = new int[128];
        memset(hostA, 0, sizeof(int)*128);
        int* d;
        cudaError_t e1 = cudaMalloc( (void**) &d, sizeof(int)*128 );
        std::cout << "alloc = " << d << " err = " << e1 << std::endl;
        cudaError_t e2 = cudaFree( d );
        delete[] hostA;
        std::cout << "free  = " << d << " err = " << e2 << std::endl;
    }
    {
        cudaError_t e1 = cudaThreadExit();
        std::cout << "thread exit err = " << e1 << std::endl;
    }
    {
        int* hostA = new int[128];
        memset(hostA, 0, sizeof(int)*128);
        int* d;
        cudaError_t e1 = cudaMalloc( (void**) &d, sizeof(int)*128 );
        std::cout << "alloc = " << d << " err = " << e1 << std::endl;
    }
    std::cout << "d2 = " << d2 << std::endl;
    return 0;
}

